﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GeostatisticalTool.Forms
{
    public partial class NextPrevious : UserControl
    {
        private TabControl tab;

        public NextPrevious()
        {
            InitializeComponent();
        }

        public void  SetTab(TabControl tab)
        {

            this.tab = tab;
            tab.Selected +=new TabControlEventHandler(tab_Selected);
            uxPrevious.Visible = false;
        }


        public event EventHandler SelectedNext;

        protected virtual void OnSelectedNext(EventArgs e)
        {
            if (SelectedNext != null)
                SelectedNext(this, e);
        }

        public event EventHandler SelectedPrevious;

        protected virtual void OnSelectedPrevious(EventArgs e)
        {
            if (SelectedPrevious != null)
                SelectedPrevious(this, e);
        }




        public void CurrentTab()
        {
           // this.tab.SelectedTab
        }

        private void tab_Selected(object sender, EventArgs e)
        {
            if (tab.SelectedIndex > 0)
                uxPrevious.Visible = true;
            else
                uxPrevious.Visible = false;

            if (tab.SelectedIndex == (tab.TabCount-1))
                uxNext.Visible = false;
            else
                uxNext.Visible = true;
        }



        private void uxPrevious_Click(object sender, EventArgs e)
        {
            OnSelectedPrevious(EventArgs.Empty);
        }

        private void uxNext_Click(object sender, EventArgs e)
        {
            OnSelectedNext(EventArgs.Empty);
        }

    }
}
